home *** CD-ROM | disk | FTP | other *** search
- /********************************************************************
- FILENAME: MAINMS.CPP
- AUTHOR : JAKE HILL
- DATE : 12/1/94
-
- Copyright (c) 1994 by Jake Hill:
- If you use any part of this code in your own project, please credit
- me in your documentation and source code. Thanks.
- ********************************************************************/
-
- #define C
-
- #include "trig.h"
- #include "view.h"
- #include "keyboard.h"
-
- #ifdef __GNUC__
- #include <osbind.h>
- #else
- #include <tos.h>
- #endif
-
- #include <stdio.h>
- #include <stdlib.h>
-
- #ifdef C
- extern void ViewSetup(void);
- extern void ViewRemove(void);
- extern void OpenWad(char *, long);
- extern void Close(void);
- extern void DrawView(void);
- extern void SetView(short *, short *, short *, unsigned short *);
- extern void GetView(short *, short *, short *, unsigned short *);
- #endif
-
- extern void get_key(short *, short *);
-
- void main(int argc, char *argv[])
- {
- short Px, Py, Ph;
- long FrameCount = 0L;
- unsigned short Pangle;
- char *WadFile = "DOOM.WAD";
- short Level = 0, Step = 8, Turn = 1024;
- int index = 0;
- short key, key_flags;
-
- printf("This program was originally written for the PC by Jake Hill\n");
- printf("(jkhil@dbsoftware.com) and was released Decemeber 1, 1994.\n");
- printf("According to Jake's wishes, the full DVIEW sources and read.me\n");
- printf("file must be included with any distribution.\n\n");
- printf("The conversion to the Atari Falcon and TT was done by\n");
- printf("Johan Klockars (d8klojo@dtek.chalmers.se).\n");
- printf("The Copyright (1994) of the Atari assembly chunky to planar\n");
- printf("routine is owned by Johan Klockars, but is available on\n");
- printf("request for use in other FreeWare (and similar) software.\n");
- printf("-------------------------------------------------------\n");
- printf("Up to two parameters can be given. The last one is the level\n");
- printf("number to view, but the name of a .WAD file to load can be\n");
- printf("given before that.\n\n");
- printf("Move around using 8/2, 4/6, 1/3 and +/-, preferably on the\n");
- printf("numeric keyboard. Quit by pressing ESC a couple of times.\n");
- printf("More colours: f/w. Low memory operation F/W.\n");
- printf("Single step drawing (depends on mode): s. Your position: p\n");
- printf("\n");
-
- #ifndef C
- View Map;
- #else
- ViewSetup();
- #endif
-
- if (argc == 2)
- Level = atoi(argv[1]);
- else if (argc == 3) {
- WadFile = argv[1];
- Level = atoi(argv[2]);
- }
- #ifndef C
- Map.OpenWad(WadFile, Level);
- #else
- OpenWad(WadFile, Level);
- #endif
-
- SetKeyboardInt();
-
- #ifndef C
- Map.GetView(&Px, &Py, &Ph, &Pangle);
- #else
- GetView(&Px, &Py, &Ph, &Pangle);
- #endif
-
- printf("Let's get started then...\n");
-
- #ifndef C
- Map.SetView(Px,Py,Ph,Pangle);
- Map.DrawView();
- #else
- SetView(&Px, &Py, &Ph, &Pangle);
- DrawView();
- #endif
-
- #if 0
- float T1,T2,dT;
- struct _dostime_t t1,t2;
- _dos_gettime(&t1);
- #endif
-
- get_key(&key, &key_flags);
-
- while (key != 1) {
- FrameCount++;
-
- while (key == -1)
- get_key(&key, &key_flags);
-
- while ((key != -1) && (key != 1)) {
- if (key_flags & FLAG_UP) {
- Px += xCosA( Step, Pangle );
- Py += xSinA( Step, Pangle );
- }
- if (key_flags & FLAG_DOWN) {
- Px -= xCosA(Step, Pangle);
- Py -= xSinA(Step, Pangle);
- }
-
- if ((key_flags & FLAG_SRIGHT) == FLAG_SRIGHT) {
- Px += xCosA(Step, Pangle-0x4000);
- Py += xSinA(Step, Pangle-0x4000);
- } else if (key_flags & FLAG_RIGHT)
- Pangle -= Turn;
-
- if ((key_flags & FLAG_SLEFT) == FLAG_SLEFT) {
- Px += xCosA(Step, Pangle+0x4000);
- Py += xSinA(Step, Pangle+0x4000);
- } else if (key_flags & FLAG_LEFT)
- Pangle += Turn;
-
- if (key == KEY_PLUS)
- Ph += 10;
-
- if (key == KEY_MINUS)
- Ph -= 10;
-
- get_key(&key, &key_flags);
- }
- #ifndef C
- Map.SetView(Px,Py,Ph,Pangle);
- Map.DrawView();
- #else
- SetView(&Px, &Py, &Ph, &Pangle);
- DrawView();
- #endif
-
- #if 0
- printf("Frame: %ld\n", FrameCount);
- #endif
- get_key(&key, &key_flags);
- }
-
- printf("\n");
-
- #if 0
- _dos_gettime(&t2);
- #endif
- #ifndef C
- Map.Close();
- #else
- Close();
- #endif
-
- #if 0
- T1 = t1.hsecond+(t1.second*100)+(t1.minute*6000);
- T2 = t2.hsecond+(t2.second*100)+(t2.minute*6000);
- dT = T2 - T1;
- float fps = (float) FrameCount / ( (float) dT / 100 );
- #endif
-
- ResetKeyboardInt();
-
- printf("\n");
- #if 0
- printf("FPS = %f\n",fps);
- printf("Elapsed Time = %4.2f\n",dT/100);
- #endif
- #ifdef C
- ViewRemove();
- #endif
- }
-